source("../../lib/som-utils.R")
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
source("../../lib/maps-utils.R")
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
mpr.set_base_path_analysis()
model <- mpr.load_model("som-146.rds.xz")
summary(model)
SOM of size 5x5 with a hexagonal topology and a bubble neighbourhood function.
The number of data layers is 1.
Distance measure(s) used: sumofsquares.
Training data included: 156652 objects.
Mean distance to the closest unit in the map: 0.762.
plot(model, type="changes")
df <- mpr.load_data("datos_semana_2k.csv.xz")
df
summary(df)
id_estacion fecha fecha_cnt tmax
Length:156652 Length:156652 Min. : 1.00 Min. :-109.0
Class :character Class :character 1st Qu.:13.00 1st Qu.: 147.0
Mode :character Mode :character Median :27.00 Median : 201.0
Mean :26.53 Mean : 202.1
3rd Qu.:40.00 3rd Qu.: 262.0
Max. :53.00 Max. : 442.0
tmin precip nevada prof_nieve
Min. :-189.00 Min. : 0.00 Min. :0 Min. : 0.000
1st Qu.: 48.00 1st Qu.: 0.00 1st Qu.:0 1st Qu.: 0.000
Median : 98.00 Median : 3.00 Median :0 Median : 0.000
Mean : 98.13 Mean : 16.92 Mean :0 Mean : 0.604
3rd Qu.: 152.00 3rd Qu.: 20.00 3rd Qu.:0 3rd Qu.: 0.000
Max. : 272.00 Max. :690.00 Max. :0 Max. :1073.000
longitud latitud altitud
Min. :27.82 Min. :-17.889 Min. : 1.0
1st Qu.:39.01 1st Qu.: -4.850 1st Qu.: 44.0
Median :41.22 Median : -1.411 Median : 263.0
Mean :40.05 Mean : -2.426 Mean : 478.5
3rd Qu.:42.19 3rd Qu.: 1.272 3rd Qu.: 687.0
Max. :43.57 Max. : 4.216 Max. :2535.0
world <- ne_countries(scale = "medium", returnclass = "sf")
spain <- subset(world, admin == "Spain")
plot(model, type="count", shape = "straight", palette.name = mpr.degrade.bleu)
NĂºmero de elementos en cada celda:
nb <- table(model$unit.classif)
print(nb)
1 2 3 4 5 6 7 8 9 10 11 12 13
1129 4802 8754 11403 6494 8667 3808 6129 7412 8073 6526 6818 6794
14 15 16 17 18 19 20 21 22 23 24 25
2170 3523 13006 5402 3958 5726 7587 6399 7265 3924 7436 3447
ComprobaciĂ³n de nodos vacĂos:
dim_model <- 5*5;
len_nb = length(nb);
empty_nodes <- dim_model != len_nb;
if (empty_nodes) {
print(paste("[Warning] Existen nodos vacĂos: ", len_nb, "/", dim_model))
}
plot(model, type="dist.neighbours", shape = "straight")
model_colnames = c("fecha_cnt", "tmax", "tmin", "longitud", "latitud", "altitud")
model_ncol = length(model_colnames)
plot(model, shape = "straight")
par(mfrow=c(3,4))
for (j in 1:model_ncol) {
plot(model, type="property", property=getCodes(model,1)[,j],
palette.name=mpr.coolBlueHotRed,
main=model_colnames[j],
cex=0.5, shape = "straight")
}
if (!empty_nodes) {
cor <- apply(getCodes(model,1), 2, mpr.weighted.correlation, w=nb, som=model)
print(cor)
}
fecha_cnt tmax tmin longitud latitud altitud
[1,] -0.1258577 -0.7863477 -0.8776624 0.4875899 0.3554488 0.33366235
[2,] 0.8367984 0.2412784 0.2400860 0.2108061 0.1860183 0.06316609
RepresentaciĂ³n de cada variable en un mapa de factores:
if (!empty_nodes) {
par(mfrow=c(1,1))
plot(cor[1,], cor[2,], xlim=c(-1,1), ylim=c(-1,1), type="n")
lines(c(-1,1),c(0,0))
lines(c(0,0),c(-1,1))
text(cor[1,], cor[2,], labels=model_colnames, cex=0.75)
symbols(0,0,circles=1,inches=F,add=T)
}
Importancia de cada variable - varianza ponderada por el tamaño de la celda:
if (!empty_nodes) {
sigma2 <- sqrt(apply(getCodes(model,1),2,function(x,effectif)
{m<-sum(effectif*(x-weighted.mean(x,effectif))^2)/(sum(effectif)-1)},
effectif=nb))
print(sort(sigma2,decreasing=T))
}
longitud altitud tmax latitud fecha_cnt tmin
0.9620169 0.9448578 0.9339194 0.9333579 0.9278264 0.9161442
if (!empty_nodes) {
hac <- mpr.hac(model, nb)
}
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=3)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=3)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.0 Min. : -5.0 Min. :-51 Min. : 0.00 Min. :0
1st Qu.:13.0 1st Qu.:211.0 1st Qu.:148 1st Qu.: 0.00 1st Qu.:0
Median :26.0 Median :234.0 Median :172 Median : 0.00 Median :0
Mean :26.3 Mean :229.4 Mean :165 Mean : 6.28 Mean :0
3rd Qu.:39.0 3rd Qu.:262.0 3rd Qu.:201 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.0 Max. :384.0 Max. :263 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-16.56 1st Qu.: 25.0
Median :0 Median :28.44 Median :-16.33 Median : 33.0
Mean :0 Mean :28.35 Mean :-16.04 Mean : 371.2
3rd Qu.:0 3rd Qu.:28.48 3rd Qu.:-15.39 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :2371.0
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :-31.0 Min. :-161.0 Min. : 0.00 Min. :0
1st Qu.:13.00 1st Qu.:152.0 1st Qu.: 52.0 1st Qu.: 0.00 1st Qu.:0
Median :26.00 Median :203.0 Median : 99.0 Median : 3.00 Median :0
Mean :26.51 Mean :208.6 Mean : 99.4 Mean : 16.49 Mean :0
3rd Qu.:40.00 3rd Qu.:267.0 3rd Qu.: 149.0 3rd Qu.: 20.00 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. : 272.0 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.624 Min. : 1
1st Qu.: 0.00000 1st Qu.:39.56 1st Qu.:-4.488 1st Qu.: 52
Median : 0.00000 Median :41.29 Median :-1.293 Median : 258
Mean : 0.06506 Mean :40.73 Mean :-1.679 Mean : 368
3rd Qu.: 0.00000 3rd Qu.:42.12 3rd Qu.: 1.296 3rd Qu.: 628
Max. :299.00000 Max. :43.57 Max. : 4.216 Max. :1894
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.:14.00 1st Qu.: 29.00 1st Qu.: -33.00 1st Qu.: 3.0
Median :27.00 Median : 76.00 Median : 10.00 Median : 19.0
Mean :26.92 Mean : 81.71 Mean : 12.07 Mean : 33.9
3rd Qu.:40.00 3rd Qu.: 136.00 3rd Qu.: 60.00 3rd Qu.: 48.0
Max. :53.00 Max. : 249.00 Max. : 154.00 Max. :615.0
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.000 Min. :40.78 Min. :-4.0103
1st Qu.:0 1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789
Median :0 Median : 0.000 Median :42.47 Median : 1.0544
Mean :0 Mean : 8.879 Mean :42.25 Mean : 0.7657
3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150
Max. :0 Max. :1073.000 Max. :42.77 Max. : 2.4378
altitud
Min. :1056
1st Qu.:1971
Median :2230
Mean :2157
3rd Qu.:2400
Max. :2535
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=4)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=4)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.0 Min. : -5.0 Min. :-51 Min. : 0.00 Min. :0
1st Qu.:13.0 1st Qu.:211.0 1st Qu.:148 1st Qu.: 0.00 1st Qu.:0
Median :26.0 Median :234.0 Median :172 Median : 0.00 Median :0
Mean :26.3 Mean :229.4 Mean :165 Mean : 6.28 Mean :0
3rd Qu.:39.0 3rd Qu.:262.0 3rd Qu.:201 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.0 Max. :384.0 Max. :263 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-16.56 1st Qu.: 25.0
Median :0 Median :28.44 Median :-16.33 Median : 33.0
Mean :0 Mean :28.35 Mean :-16.04 Mean : 371.2
3rd Qu.:0 3rd Qu.:28.48 3rd Qu.:-15.39 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :2371.0
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :-22.0 Min. :-161.00 Min. : 0.00 Min. :0
1st Qu.: 6.00 1st Qu.:134.0 1st Qu.: 31.00 1st Qu.: 0.00 1st Qu.:0
Median :11.00 Median :168.0 Median : 65.00 Median : 6.00 Median :0
Mean :11.38 Mean :168.5 Mean : 63.78 Mean : 18.56 Mean :0
3rd Qu.:17.00 3rd Qu.:203.0 3rd Qu.: 97.00 3rd Qu.: 24.00 3rd Qu.:0
Max. :31.00 Max. :327.0 Max. : 195.00 Max. :608.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.624 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:39.49 1st Qu.:-4.127 1st Qu.: 47.0
Median : 0.0000 Median :41.29 Median :-1.169 Median : 251.0
Mean : 0.1057 Mean :40.71 Mean :-1.577 Mean : 360.4
3rd Qu.: 0.0000 3rd Qu.:42.11 3rd Qu.: 1.363 3rd Qu.: 626.0
Max. :299.0000 Max. :43.57 Max. : 4.216 Max. :1894.0
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip nevada
Min. :13.00 Min. :-31.0 Min. :-155.0 Min. : 0.00 Min. :0
1st Qu.:30.00 1st Qu.:181.0 1st Qu.: 83.0 1st Qu.: 0.00 1st Qu.:0
Median :37.00 Median :249.0 Median : 132.0 Median : 2.00 Median :0
Mean :37.23 Mean :236.9 Mean : 124.6 Mean : 15.02 Mean :0
3rd Qu.:45.00 3rd Qu.:295.0 3rd Qu.: 172.0 3rd Qu.: 16.00 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. : 272.0 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.624 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:39.56 1st Qu.:-4.488 1st Qu.: 52.0
Median : 0.00000 Median :41.29 Median :-1.411 Median : 261.0
Mean : 0.03625 Mean :40.75 Mean :-1.752 Mean : 373.4
3rd Qu.: 0.00000 3rd Qu.:42.12 3rd Qu.: 1.179 3rd Qu.: 639.0
Max. :290.00000 Max. :43.57 Max. : 4.216 Max. :1894.0
if (!empty_nodes) summary(df.cluster04)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.:14.00 1st Qu.: 29.00 1st Qu.: -33.00 1st Qu.: 3.0
Median :27.00 Median : 76.00 Median : 10.00 Median : 19.0
Mean :26.92 Mean : 81.71 Mean : 12.07 Mean : 33.9
3rd Qu.:40.00 3rd Qu.: 136.00 3rd Qu.: 60.00 3rd Qu.: 48.0
Max. :53.00 Max. : 249.00 Max. : 154.00 Max. :615.0
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.000 Min. :40.78 Min. :-4.0103
1st Qu.:0 1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789
Median :0 Median : 0.000 Median :42.47 Median : 1.0544
Mean :0 Mean : 8.879 Mean :42.25 Mean : 0.7657
3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150
Max. :0 Max. :1073.000 Max. :42.77 Max. : 2.4378
altitud
Min. :1056
1st Qu.:1971
Median :2230
Mean :2157
3rd Qu.:2400
Max. :2535
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=5)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=5)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.0 Min. : -5.0 Min. :-51 Min. : 0.00 Min. :0
1st Qu.:13.0 1st Qu.:211.0 1st Qu.:148 1st Qu.: 0.00 1st Qu.:0
Median :26.0 Median :234.0 Median :172 Median : 0.00 Median :0
Mean :26.3 Mean :229.4 Mean :165 Mean : 6.28 Mean :0
3rd Qu.:39.0 3rd Qu.:262.0 3rd Qu.:201 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.0 Max. :384.0 Max. :263 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-16.56 1st Qu.: 25.0
Median :0 Median :28.44 Median :-16.33 Median : 33.0
Mean :0 Mean :28.35 Mean :-16.04 Mean : 371.2
3rd Qu.:0 3rd Qu.:28.48 3rd Qu.:-15.39 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :2371.0
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :-22.0 Min. :-161.00 Min. : 0.00 Min. :0
1st Qu.: 6.00 1st Qu.:134.0 1st Qu.: 31.00 1st Qu.: 0.00 1st Qu.:0
Median :11.00 Median :168.0 Median : 65.00 Median : 6.00 Median :0
Mean :11.38 Mean :168.5 Mean : 63.78 Mean : 18.56 Mean :0
3rd Qu.:17.00 3rd Qu.:203.0 3rd Qu.: 97.00 3rd Qu.: 24.00 3rd Qu.:0
Max. :31.00 Max. :327.0 Max. : 195.00 Max. :608.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.624 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:39.49 1st Qu.:-4.127 1st Qu.: 47.0
Median : 0.0000 Median :41.29 Median :-1.169 Median : 251.0
Mean : 0.1057 Mean :40.71 Mean :-1.577 Mean : 360.4
3rd Qu.: 0.0000 3rd Qu.:42.11 3rd Qu.: 1.363 3rd Qu.: 626.0
Max. :299.0000 Max. :43.57 Max. : 4.216 Max. :1894.0
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip nevada
Min. :14.00 Min. :164.0 Min. : 39.0 Min. : 0.000 Min. :0
1st Qu.:27.00 1st Qu.:262.0 1st Qu.:134.0 1st Qu.: 0.000 1st Qu.:0
Median :32.00 Median :289.0 Median :165.0 Median : 0.000 Median :0
Mean :32.22 Mean :288.5 Mean :163.2 Mean : 9.955 Mean :0
3rd Qu.:37.00 3rd Qu.:315.0 3rd Qu.:191.0 3rd Qu.: 9.000 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. :272.0 Max. :610.000 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:38.99 1st Qu.:-3.7225 1st Qu.: 43.3
Median : 0.0000 Median :40.95 Median : 0.3264 Median : 247.0
Mean : 0.0048 Mean :40.33 Mean :-0.9801 Mean : 361.9
3rd Qu.: 0.0000 3rd Qu.:41.67 3rd Qu.: 1.4181 3rd Qu.: 628.0
Max. :173.0000 Max. :43.36 Max. : 4.2156 Max. :1894.0
if (!empty_nodes) summary(df.cluster04)
fecha_cnt tmax tmin precip nevada
Min. :13.00 Min. :-31.0 Min. :-155.00 Min. : 0.00 Min. :0
1st Qu.:41.00 1st Qu.:132.0 1st Qu.: 38.00 1st Qu.: 0.00 1st Qu.:0
Median :46.00 Median :170.0 Median : 74.00 Median : 7.00 Median :0
Mean :43.73 Mean :169.9 Mean : 74.51 Mean : 21.61 Mean :0
3rd Qu.:49.00 3rd Qu.:208.0 3rd Qu.: 112.00 3rd Qu.: 27.00 3rd Qu.:0
Max. :53.00 Max. :346.0 Max. : 211.00 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:40.66 1st Qu.:-5.6983 1st Qu.: 61.0
Median : 0.00000 Median :41.70 Median :-2.9056 Median : 316.0
Mean : 0.07711 Mean :41.30 Mean :-2.7542 Mean : 388.4
3rd Qu.: 0.00000 3rd Qu.:42.70 3rd Qu.: 0.7433 3rd Qu.: 656.0
Max. :290.00000 Max. :43.57 Max. : 4.2156 Max. :1572.0
if (!empty_nodes) summary(df.cluster05)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.:14.00 1st Qu.: 29.00 1st Qu.: -33.00 1st Qu.: 3.0
Median :27.00 Median : 76.00 Median : 10.00 Median : 19.0
Mean :26.92 Mean : 81.71 Mean : 12.07 Mean : 33.9
3rd Qu.:40.00 3rd Qu.: 136.00 3rd Qu.: 60.00 3rd Qu.: 48.0
Max. :53.00 Max. : 249.00 Max. : 154.00 Max. :615.0
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.000 Min. :40.78 Min. :-4.0103
1st Qu.:0 1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789
Median :0 Median : 0.000 Median :42.47 Median : 1.0544
Mean :0 Mean : 8.879 Mean :42.25 Mean : 0.7657
3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150
Max. :0 Max. :1073.000 Max. :42.77 Max. : 2.4378
altitud
Min. :1056
1st Qu.:1971
Median :2230
Mean :2157
3rd Qu.:2400
Max. :2535
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=6)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=6)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : -5.0 Min. :-51.00 Min. : 0.000 Min. :0
1st Qu.:13.00 1st Qu.:101.0 1st Qu.: 27.00 1st Qu.: 0.000 1st Qu.:0
Median :26.00 Median :140.0 Median : 60.00 Median : 0.000 Median :0
Mean :26.33 Mean :144.1 Mean : 67.88 Mean : 9.353 Mean :0
3rd Qu.:39.00 3rd Qu.:190.0 3rd Qu.:109.00 3rd Qu.: 3.000 3rd Qu.:0
Max. :53.00 Max. :263.0 Max. :184.00 Max. :316.000 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :28.31 Min. :-16.5 Min. :2371
1st Qu.:0 1st Qu.:28.31 1st Qu.:-16.5 1st Qu.:2371
Median :0 Median :28.31 Median :-16.5 Median :2371
Mean :0 Mean :28.31 Mean :-16.5 Mean :2371
3rd Qu.:0 3rd Qu.:28.31 3rd Qu.:-16.5 3rd Qu.:2371
Max. :0 Max. :28.31 Max. :-16.5 Max. :2371
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :-22.0 Min. :-161.00 Min. : 0.00 Min. :0
1st Qu.: 6.00 1st Qu.:134.0 1st Qu.: 31.00 1st Qu.: 0.00 1st Qu.:0
Median :11.00 Median :168.0 Median : 65.00 Median : 6.00 Median :0
Mean :11.38 Mean :168.5 Mean : 63.78 Mean : 18.56 Mean :0
3rd Qu.:17.00 3rd Qu.:203.0 3rd Qu.: 97.00 3rd Qu.: 24.00 3rd Qu.:0
Max. :31.00 Max. :327.0 Max. : 195.00 Max. :608.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.624 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:39.49 1st Qu.:-4.127 1st Qu.: 47.0
Median : 0.0000 Median :41.29 Median :-1.169 Median : 251.0
Mean : 0.1057 Mean :40.71 Mean :-1.577 Mean : 360.4
3rd Qu.: 0.0000 3rd Qu.:42.11 3rd Qu.: 1.363 3rd Qu.: 626.0
Max. :299.0000 Max. :43.57 Max. : 4.216 Max. :1894.0
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :126.0 Min. : 67.0 Min. : 0.00 Min. :0
1st Qu.:13.00 1st Qu.:218.0 1st Qu.:157.0 1st Qu.: 0.00 1st Qu.:0
Median :26.00 Median :239.0 Median :177.0 Median : 0.00 Median :0
Mean :26.29 Mean :240.5 Mean :177.7 Mean : 5.88 Mean :0
3rd Qu.:39.00 3rd Qu.:265.0 3rd Qu.:205.0 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.00 Max. :384.0 Max. :263.0 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-17.75 1st Qu.: 25.0
Median :0 Median :28.46 Median :-16.33 Median : 33.0
Mean :0 Mean :28.36 Mean :-15.98 Mean :110.7
3rd Qu.:0 3rd Qu.:28.63 3rd Qu.:-13.86 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :632.0
if (!empty_nodes) summary(df.cluster04)
fecha_cnt tmax tmin precip nevada
Min. :14.00 Min. :164.0 Min. : 39.0 Min. : 0.000 Min. :0
1st Qu.:27.00 1st Qu.:262.0 1st Qu.:134.0 1st Qu.: 0.000 1st Qu.:0
Median :32.00 Median :289.0 Median :165.0 Median : 0.000 Median :0
Mean :32.22 Mean :288.5 Mean :163.2 Mean : 9.955 Mean :0
3rd Qu.:37.00 3rd Qu.:315.0 3rd Qu.:191.0 3rd Qu.: 9.000 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. :272.0 Max. :610.000 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:38.99 1st Qu.:-3.7225 1st Qu.: 43.3
Median : 0.0000 Median :40.95 Median : 0.3264 Median : 247.0
Mean : 0.0048 Mean :40.33 Mean :-0.9801 Mean : 361.9
3rd Qu.: 0.0000 3rd Qu.:41.67 3rd Qu.: 1.4181 3rd Qu.: 628.0
Max. :173.0000 Max. :43.36 Max. : 4.2156 Max. :1894.0
if (!empty_nodes) summary(df.cluster05)
fecha_cnt tmax tmin precip nevada
Min. :13.00 Min. :-31.0 Min. :-155.00 Min. : 0.00 Min. :0
1st Qu.:41.00 1st Qu.:132.0 1st Qu.: 38.00 1st Qu.: 0.00 1st Qu.:0
Median :46.00 Median :170.0 Median : 74.00 Median : 7.00 Median :0
Mean :43.73 Mean :169.9 Mean : 74.51 Mean : 21.61 Mean :0
3rd Qu.:49.00 3rd Qu.:208.0 3rd Qu.: 112.00 3rd Qu.: 27.00 3rd Qu.:0
Max. :53.00 Max. :346.0 Max. : 211.00 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:40.66 1st Qu.:-5.6983 1st Qu.: 61.0
Median : 0.00000 Median :41.70 Median :-2.9056 Median : 316.0
Mean : 0.07711 Mean :41.30 Mean :-2.7542 Mean : 388.4
3rd Qu.: 0.00000 3rd Qu.:42.70 3rd Qu.: 0.7433 3rd Qu.: 656.0
Max. :290.00000 Max. :43.57 Max. : 4.2156 Max. :1572.0
if (!empty_nodes) summary(df.cluster06)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.:14.00 1st Qu.: 29.00 1st Qu.: -33.00 1st Qu.: 3.0
Median :27.00 Median : 76.00 Median : 10.00 Median : 19.0
Mean :26.92 Mean : 81.71 Mean : 12.07 Mean : 33.9
3rd Qu.:40.00 3rd Qu.: 136.00 3rd Qu.: 60.00 3rd Qu.: 48.0
Max. :53.00 Max. : 249.00 Max. : 154.00 Max. :615.0
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.000 Min. :40.78 Min. :-4.0103
1st Qu.:0 1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789
Median :0 Median : 0.000 Median :42.47 Median : 1.0544
Mean :0 Mean : 8.879 Mean :42.25 Mean : 0.7657
3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150
Max. :0 Max. :1073.000 Max. :42.77 Max. : 2.4378
altitud
Min. :1056
1st Qu.:1971
Median :2230
Mean :2157
3rd Qu.:2400
Max. :2535
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=8)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=8)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : -5.0 Min. :-51.00 Min. : 0.000 Min. :0
1st Qu.:13.00 1st Qu.:101.0 1st Qu.: 27.00 1st Qu.: 0.000 1st Qu.:0
Median :26.00 Median :140.0 Median : 60.00 Median : 0.000 Median :0
Mean :26.33 Mean :144.1 Mean : 67.88 Mean : 9.353 Mean :0
3rd Qu.:39.00 3rd Qu.:190.0 3rd Qu.:109.00 3rd Qu.: 3.000 3rd Qu.:0
Max. :53.00 Max. :263.0 Max. :184.00 Max. :316.000 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :28.31 Min. :-16.5 Min. :2371
1st Qu.:0 1st Qu.:28.31 1st Qu.:-16.5 1st Qu.:2371
Median :0 Median :28.31 Median :-16.5 Median :2371
Mean :0 Mean :28.31 Mean :-16.5 Mean :2371
3rd Qu.:0 3rd Qu.:28.31 3rd Qu.:-16.5 3rd Qu.:2371
Max. :0 Max. :28.31 Max. :-16.5 Max. :2371
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : 66.0 Min. :-29.00 Min. : 0.00 Min. :0
1st Qu.: 8.00 1st Qu.:158.0 1st Qu.: 56.00 1st Qu.: 0.00 1st Qu.:0
Median :13.00 Median :184.0 Median : 80.00 Median : 6.00 Median :0
Mean :12.91 Mean :187.5 Mean : 82.26 Mean : 19.13 Mean :0
3rd Qu.:18.00 3rd Qu.:215.0 3rd Qu.:107.00 3rd Qu.: 25.00 3rd Qu.:0
Max. :31.00 Max. :327.0 Max. :195.00 Max. :523.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.000 Min. :35.28 Min. :-8.624 Min. : 1.0
1st Qu.: 0.000 1st Qu.:38.88 1st Qu.:-4.846 1st Qu.: 32.0
Median : 0.000 Median :41.17 Median :-1.008 Median : 91.1
Mean : 0.036 Mean :40.49 Mean :-1.596 Mean : 246.4
3rd Qu.: 0.000 3rd Qu.:42.07 3rd Qu.: 1.384 3rd Qu.: 405.0
Max. :164.000 Max. :43.57 Max. : 4.216 Max. :1572.0
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip
Min. : 1.000 Min. :-22.0 Min. :-161.000 Min. : 0.00
1st Qu.: 3.000 1st Qu.: 90.0 1st Qu.: -11.000 1st Qu.: 0.00
Median : 6.000 Median :112.0 Median : 9.000 Median : 7.00
Mean : 6.667 Mean :109.9 Mean : 6.656 Mean : 16.79
3rd Qu.: 9.000 3rd Qu.:132.0 3rd Qu.: 27.000 3rd Qu.: 22.00
Max. :28.000 Max. :200.0 Max. : 84.000 Max. :608.00
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.0000 Min. :37.16 Min. :-8.624
1st Qu.:0 1st Qu.: 0.0000 1st Qu.:40.70 1st Qu.:-3.789
Median :0 Median : 0.0000 Median :41.65 Median :-1.861
Mean :0 Mean : 0.3212 Mean :41.39 Mean :-1.517
3rd Qu.:0 3rd Qu.: 0.0000 3rd Qu.:42.22 3rd Qu.: 1.296
Max. :0 Max. :299.0000 Max. :43.36 Max. : 4.216
altitud
Min. : 2.0
1st Qu.: 515.0
Median : 704.0
Mean : 712.5
3rd Qu.: 900.0
Max. :1894.0
if (!empty_nodes) summary(df.cluster04)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :126.0 Min. : 67.0 Min. : 0.00 Min. :0
1st Qu.:13.00 1st Qu.:218.0 1st Qu.:157.0 1st Qu.: 0.00 1st Qu.:0
Median :26.00 Median :239.0 Median :177.0 Median : 0.00 Median :0
Mean :26.29 Mean :240.5 Mean :177.7 Mean : 5.88 Mean :0
3rd Qu.:39.00 3rd Qu.:265.0 3rd Qu.:205.0 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.00 Max. :384.0 Max. :263.0 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-17.75 1st Qu.: 25.0
Median :0 Median :28.46 Median :-16.33 Median : 33.0
Mean :0 Mean :28.36 Mean :-15.98 Mean :110.7
3rd Qu.:0 3rd Qu.:28.63 3rd Qu.:-13.86 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :632.0
if (!empty_nodes) summary(df.cluster05)
fecha_cnt tmax tmin precip nevada
Min. :14.00 Min. :164.0 Min. : 39.0 Min. : 0.000 Min. :0
1st Qu.:27.00 1st Qu.:262.0 1st Qu.:134.0 1st Qu.: 0.000 1st Qu.:0
Median :32.00 Median :289.0 Median :165.0 Median : 0.000 Median :0
Mean :32.22 Mean :288.5 Mean :163.2 Mean : 9.955 Mean :0
3rd Qu.:37.00 3rd Qu.:315.0 3rd Qu.:191.0 3rd Qu.: 9.000 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. :272.0 Max. :610.000 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:38.99 1st Qu.:-3.7225 1st Qu.: 43.3
Median : 0.0000 Median :40.95 Median : 0.3264 Median : 247.0
Mean : 0.0048 Mean :40.33 Mean :-0.9801 Mean : 361.9
3rd Qu.: 0.0000 3rd Qu.:41.67 3rd Qu.: 1.4181 3rd Qu.: 628.0
Max. :173.0000 Max. :43.36 Max. : 4.2156 Max. :1894.0
if (!empty_nodes) summary(df.cluster06)
fecha_cnt tmax tmin precip nevada
Min. :13.00 Min. : 63.0 Min. :-35.0 Min. : 0.00 Min. :0
1st Qu.:31.00 1st Qu.:170.0 1st Qu.: 87.0 1st Qu.: 1.00 1st Qu.:0
Median :42.00 Median :205.0 Median :120.0 Median : 11.00 Median :0
Mean :39.25 Mean :201.6 Mean :114.9 Mean : 28.26 Mean :0
3rd Qu.:47.00 3rd Qu.:233.0 3rd Qu.:146.0 3rd Qu.: 38.00 3rd Qu.:0
Max. :53.00 Max. :346.0 Max. :211.0 Max. :422.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:38.00 1st Qu.:-7.8603 1st Qu.: 42.0
Median : 0.00000 Median :42.89 Median :-6.0442 Median : 98.0
Mean : 0.09183 Mean :41.39 Mean :-5.8760 Mean :160.5
3rd Qu.: 0.00000 3rd Qu.:43.36 3rd Qu.:-3.8314 3rd Qu.:261.0
Max. :290.00000 Max. :43.57 Max. : 0.8031 Max. :916.0
if (!empty_nodes) summary(df.cluster07)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.:14.00 1st Qu.: 29.00 1st Qu.: -33.00 1st Qu.: 3.0
Median :27.00 Median : 76.00 Median : 10.00 Median : 19.0
Mean :26.92 Mean : 81.71 Mean : 12.07 Mean : 33.9
3rd Qu.:40.00 3rd Qu.: 136.00 3rd Qu.: 60.00 3rd Qu.: 48.0
Max. :53.00 Max. : 249.00 Max. : 154.00 Max. :615.0
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.000 Min. :40.78 Min. :-4.0103
1st Qu.:0 1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789
Median :0 Median : 0.000 Median :42.47 Median : 1.0544
Mean :0 Mean : 8.879 Mean :42.25 Mean : 0.7657
3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150
Max. :0 Max. :1073.000 Max. :42.77 Max. : 2.4378
altitud
Min. :1056
1st Qu.:1971
Median :2230
Mean :2157
3rd Qu.:2400
Max. :2535
if (!empty_nodes) summary(df.cluster08)
fecha_cnt tmax tmin precip nevada
Min. :29.0 Min. :-31.0 Min. :-155.00 Min. : 0.00 Min. :0
1st Qu.:44.0 1st Qu.:115.0 1st Qu.: 20.00 1st Qu.: 0.00 1st Qu.:0
Median :47.0 Median :149.0 Median : 50.00 Median : 4.00 Median :0
Mean :46.8 Mean :148.3 Mean : 46.88 Mean : 17.06 Mean :0
3rd Qu.:50.0 3rd Qu.:181.0 3rd Qu.: 77.00 3rd Qu.: 21.00 3rd Qu.:0
Max. :53.0 Max. :286.0 Max. : 144.00 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :37.19 Min. :-8.4106 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:40.70 1st Qu.:-3.1742 1st Qu.: 192.0
Median : 0.00000 Median :41.48 Median : 0.3994 Median : 594.0
Mean : 0.06704 Mean :41.23 Mean :-0.6194 Mean : 544.3
3rd Qu.: 0.00000 3rd Qu.:42.07 3rd Qu.: 1.6531 3rd Qu.: 846.0
Max. :148.00000 Max. :43.43 Max. : 4.2156 Max. :1572.0
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=10)
}
A quĂ© clĂºster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=10)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clĂºster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clĂºster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
df.cluster09 <- subset(df, cluster==9)
df.cluster10 <- subset(df, cluster==10)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster09 <- select(df.cluster09, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster10 <- select(df.cluster10, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : -5.0 Min. :-51.00 Min. : 0.000 Min. :0
1st Qu.:13.00 1st Qu.:101.0 1st Qu.: 27.00 1st Qu.: 0.000 1st Qu.:0
Median :26.00 Median :140.0 Median : 60.00 Median : 0.000 Median :0
Mean :26.33 Mean :144.1 Mean : 67.88 Mean : 9.353 Mean :0
3rd Qu.:39.00 3rd Qu.:190.0 3rd Qu.:109.00 3rd Qu.: 3.000 3rd Qu.:0
Max. :53.00 Max. :263.0 Max. :184.00 Max. :316.000 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :28.31 Min. :-16.5 Min. :2371
1st Qu.:0 1st Qu.:28.31 1st Qu.:-16.5 1st Qu.:2371
Median :0 Median :28.31 Median :-16.5 Median :2371
Mean :0 Mean :28.31 Mean :-16.5 Mean :2371
3rd Qu.:0 3rd Qu.:28.31 3rd Qu.:-16.5 3rd Qu.:2371
Max. :0 Max. :28.31 Max. :-16.5 Max. :2371
if (!empty_nodes) summary(df.cluster02)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : 86.0 Min. :-29.00 Min. : 0.00 Min. :0
1st Qu.: 6.00 1st Qu.:171.0 1st Qu.: 73.00 1st Qu.: 0.00 1st Qu.:0
Median :12.00 Median :196.0 Median :101.00 Median : 2.00 Median :0
Mean :11.81 Mean :201.3 Mean : 99.69 Mean : 15.17 Mean :0
3rd Qu.:17.00 3rd Qu.:229.0 3rd Qu.:128.00 3rd Qu.: 19.00 3rd Qu.:0
Max. :27.00 Max. :327.0 Max. :195.00 Max. :354.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-6.949 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:36.64 1st Qu.:-6.257 1st Qu.: 21.0
Median : 0.00000 Median :37.16 Median :-5.598 Median : 47.0
Mean : 0.00964 Mean :37.12 Mean :-4.867 Mean :110.6
3rd Qu.: 0.00000 3rd Qu.:37.78 3rd Qu.:-3.789 3rd Qu.: 90.0
Max. :10.00000 Max. :39.88 Max. :-0.500 Max. :717.0
if (!empty_nodes) summary(df.cluster03)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. : 66 Min. :-29.0 Min. : 0.00 Min. :0
1st Qu.: 9.00 1st Qu.:155 1st Qu.: 53.0 1st Qu.: 0.00 1st Qu.:0
Median :14.00 Median :180 Median : 75.0 Median : 7.00 Median :0
Mean :13.18 Mean :184 Mean : 77.9 Mean : 20.13 Mean :0
3rd Qu.:18.00 3rd Qu.:212 3rd Qu.:100.0 3rd Qu.: 27.00 3rd Qu.:0
Max. :31.00 Max. :322 Max. :187.0 Max. :523.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :37.78 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:40.71 1st Qu.:-2.9056 1st Qu.: 43.0
Median : 0.00000 Median :41.52 Median : 0.5356 Median : 147.0
Mean : 0.04261 Mean :41.34 Mean :-0.7769 Mean : 280.4
3rd Qu.: 0.00000 3rd Qu.:42.27 3rd Qu.: 1.8081 3rd Qu.: 445.0
Max. :164.00000 Max. :43.57 Max. : 4.2156 Max. :1572.0
if (!empty_nodes) summary(df.cluster04)
fecha_cnt tmax tmin precip
Min. : 1.000 Min. :-22.0 Min. :-161.000 Min. : 0.00
1st Qu.: 3.000 1st Qu.: 90.0 1st Qu.: -11.000 1st Qu.: 0.00
Median : 6.000 Median :112.0 Median : 9.000 Median : 7.00
Mean : 6.667 Mean :109.9 Mean : 6.656 Mean : 16.79
3rd Qu.: 9.000 3rd Qu.:132.0 3rd Qu.: 27.000 3rd Qu.: 22.00
Max. :28.000 Max. :200.0 Max. : 84.000 Max. :608.00
nevada prof_nieve longitud latitud
Min. :0 Min. : 0.0000 Min. :37.16 Min. :-8.624
1st Qu.:0 1st Qu.: 0.0000 1st Qu.:40.70 1st Qu.:-3.789
Median :0 Median : 0.0000 Median :41.65 Median :-1.861
Mean :0 Mean : 0.3212 Mean :41.39 Mean :-1.517
3rd Qu.:0 3rd Qu.: 0.0000 3rd Qu.:42.22 3rd Qu.: 1.296
Max. :0 Max. :299.0000 Max. :43.36 Max. : 4.216
altitud
Min. : 2.0
1st Qu.: 515.0
Median : 704.0
Mean : 712.5
3rd Qu.: 900.0
Max. :1894.0
if (!empty_nodes) summary(df.cluster05)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :126.0 Min. : 67.0 Min. : 0.00 Min. :0
1st Qu.:13.00 1st Qu.:218.0 1st Qu.:157.0 1st Qu.: 0.00 1st Qu.:0
Median :26.00 Median :239.0 Median :177.0 Median : 0.00 Median :0
Mean :26.29 Mean :240.5 Mean :177.7 Mean : 5.88 Mean :0
3rd Qu.:39.00 3rd Qu.:265.0 3rd Qu.:205.0 3rd Qu.: 2.00 3rd Qu.:0
Max. :53.00 Max. :384.0 Max. :263.0 Max. :490.00 Max. :0
prof_nieve longitud latitud altitud
Min. :0 Min. :27.82 Min. :-17.89 Min. : 14.0
1st Qu.:0 1st Qu.:28.05 1st Qu.:-17.75 1st Qu.: 25.0
Median :0 Median :28.46 Median :-16.33 Median : 33.0
Mean :0 Mean :28.36 Mean :-15.98 Mean :110.7
3rd Qu.:0 3rd Qu.:28.63 3rd Qu.:-13.86 3rd Qu.: 64.0
Max. :0 Max. :28.95 Max. :-13.60 Max. :632.0
if (!empty_nodes) summary(df.cluster06)
fecha_cnt tmax tmin precip nevada
Min. :14.00 Min. :164.0 Min. : 39.0 Min. : 0.000 Min. :0
1st Qu.:27.00 1st Qu.:262.0 1st Qu.:134.0 1st Qu.: 0.000 1st Qu.:0
Median :32.00 Median :289.0 Median :165.0 Median : 0.000 Median :0
Mean :32.22 Mean :288.5 Mean :163.2 Mean : 9.955 Mean :0
3rd Qu.:37.00 3rd Qu.:315.0 3rd Qu.:191.0 3rd Qu.: 9.000 3rd Qu.:0
Max. :53.00 Max. :442.0 Max. :272.0 Max. :610.000 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.0000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.0000 1st Qu.:38.99 1st Qu.:-3.7225 1st Qu.: 43.3
Median : 0.0000 Median :40.95 Median : 0.3264 Median : 247.0
Mean : 0.0048 Mean :40.33 Mean :-0.9801 Mean : 361.9
3rd Qu.: 0.0000 3rd Qu.:41.67 3rd Qu.: 1.4181 3rd Qu.: 628.0
Max. :173.0000 Max. :43.36 Max. : 4.2156 Max. :1894.0
if (!empty_nodes) summary(df.cluster07)
fecha_cnt tmax tmin precip nevada
Min. :13.00 Min. : 63.0 Min. :-35.0 Min. : 0.00 Min. :0
1st Qu.:31.00 1st Qu.:170.0 1st Qu.: 87.0 1st Qu.: 1.00 1st Qu.:0
Median :42.00 Median :205.0 Median :120.0 Median : 11.00 Median :0
Mean :39.25 Mean :201.6 Mean :114.9 Mean : 28.26 Mean :0
3rd Qu.:47.00 3rd Qu.:233.0 3rd Qu.:146.0 3rd Qu.: 38.00 3rd Qu.:0
Max. :53.00 Max. :346.0 Max. :211.0 Max. :422.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :35.28 Min. :-8.6239 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:38.00 1st Qu.:-7.8603 1st Qu.: 42.0
Median : 0.00000 Median :42.89 Median :-6.0442 Median : 98.0
Mean : 0.09183 Mean :41.39 Mean :-5.8760 Mean :160.5
3rd Qu.: 0.00000 3rd Qu.:43.36 3rd Qu.:-3.8314 3rd Qu.:261.0
Max. :290.00000 Max. :43.57 Max. : 0.8031 Max. :916.0
if (!empty_nodes) summary(df.cluster08)
fecha_cnt tmax tmin precip nevada
Min. : 1.00 Min. :-79.0 Min. :-146.00 Min. : 0.00 Min. :0
1st Qu.:28.00 1st Qu.: 65.0 1st Qu.: 5.00 1st Qu.: 3.00 1st Qu.:0
Median :37.00 Median :119.0 Median : 48.00 Median : 16.00 Median :0
Mean :36.33 Mean :111.4 Mean : 39.91 Mean : 30.96 Mean :0
3rd Qu.:45.00 3rd Qu.:159.0 3rd Qu.: 80.00 3rd Qu.: 42.00 3rd Qu.:0
Max. :53.00 Max. :249.0 Max. : 154.00 Max. :459.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.000 Min. :40.78 Min. :-4.0103 Min. :1405
1st Qu.: 0.000 1st Qu.:42.18 1st Qu.: 0.7789 1st Qu.:1894
Median : 0.000 Median :42.47 Median : 1.0544 Median :2230
Mean : 2.267 Mean :42.23 Mean : 0.7696 Mean :2136
3rd Qu.: 0.000 3rd Qu.:42.64 3rd Qu.: 1.7150 3rd Qu.:2400
Max. :805.000 Max. :42.77 Max. : 2.4378 Max. :2535
if (!empty_nodes) summary(df.cluster09)
fecha_cnt tmax tmin precip
Min. : 1.00 Min. :-109.00 Min. :-189.00 Min. : 0.0
1st Qu.: 5.00 1st Qu.: 4.00 1st Qu.: -60.00 1st Qu.: 6.0
Median :10.00 Median : 33.00 Median : -32.00 Median : 25.0
Mean :10.55 Mean : 30.13 Mean : -36.36 Mean : 39.0
3rd Qu.:15.00 3rd Qu.: 61.00 3rd Qu.: -7.00 3rd Qu.: 55.5
Max. :26.00 Max. : 132.00 Max. : 56.00 Max. :615.0
nevada prof_nieve longitud latitud altitud
Min. :0 Min. : 0.00 Min. :40.78 Min. :-4.0103 Min. :1056
1st Qu.:0 1st Qu.: 0.00 1st Qu.:42.18 1st Qu.: 0.7789 1st Qu.:1971
Median :0 Median : 0.00 Median :42.47 Median : 1.0544 Median :2247
Mean :0 Mean : 20.38 Mean :42.28 Mean : 0.7588 Mean :2195
3rd Qu.:0 3rd Qu.: 0.00 3rd Qu.:42.64 3rd Qu.: 1.7150 3rd Qu.:2400
Max. :0 Max. :1073.00 Max. :42.77 Max. : 2.4378 Max. :2535
if (!empty_nodes) summary(df.cluster10)
fecha_cnt tmax tmin precip nevada
Min. :29.0 Min. :-31.0 Min. :-155.00 Min. : 0.00 Min. :0
1st Qu.:44.0 1st Qu.:115.0 1st Qu.: 20.00 1st Qu.: 0.00 1st Qu.:0
Median :47.0 Median :149.0 Median : 50.00 Median : 4.00 Median :0
Mean :46.8 Mean :148.3 Mean : 46.88 Mean : 17.06 Mean :0
3rd Qu.:50.0 3rd Qu.:181.0 3rd Qu.: 77.00 3rd Qu.: 21.00 3rd Qu.:0
Max. :53.0 Max. :286.0 Max. : 144.00 Max. :690.00 Max. :0
prof_nieve longitud latitud altitud
Min. : 0.00000 Min. :37.19 Min. :-8.4106 Min. : 1.0
1st Qu.: 0.00000 1st Qu.:40.70 1st Qu.:-3.1742 1st Qu.: 192.0
Median : 0.00000 Median :41.48 Median : 0.3994 Median : 594.0
Mean : 0.06704 Mean :41.23 Mean :-0.6194 Mean : 544.3
3rd Qu.: 0.00000 3rd Qu.:42.07 3rd Qu.: 1.6531 3rd Qu.: 846.0
Max. :148.00000 Max. :43.43 Max. : 4.2156 Max. :1572.0
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1], dim(df.cluster09)[1], dim(df.cluster10)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08", "cluster09", "cluster10"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.hist(df.cluster09)
if (!empty_nodes) mpr.hist(df.cluster10)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster09)
if (!empty_nodes) mpr.boxplot(df.cluster10)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
df.cluster09.grouped <- mpr.group_by_geo(df.cluster09)
df.cluster10.grouped <- mpr.group_by_geo(df.cluster10)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster09.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster10.grouped)